<%-- 
    Document   : register
    Created on : 12.02.2014, 16:59:52
    Author     : Corvus 11
--%>

<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="core" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html" pageEncoding="UTF-8"%>

<div id="dialog_register_main">
    <form:form id="register_form" commandName="registerCommandForm">
        <form:hidden id = "register_validation_error" path="validationError"/>
        <form:hidden id = "register_employee_id" path="employeeId"/>
        <table class="table no-border">
            <core:choose>
                <core:when test="${registerCommandForm.validationError == false}">
                    <col width="150">
                    <col>
                    <col width="0">
                </core:when>
                <core:otherwise>
                    <col width="150">
                    <col>
                    <col width="150">
                </core:otherwise>
            </core:choose>
               <core:choose>
                    <core:when test="${registerCommandForm.employeeId == -1}">
                        <tr>
                            <td>Офис: </td>
                            <td colspan="2" class="input-control select" data-role="input-control">
                                <select id="register_select_office" onchange="reloadEmplCombo();">
                                    <option value="NONE">Выберите офис</option>
                                    <core:forEach items="${officeNameList}" var="office">
                                        <option value="${office.id}">${office.name}</option>
                                    </core:forEach>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td>Сотрудник: </td>
                            <td colspan="2" class="input-control select" data-role="input-control">
                                <select id="register_select_employee" onchange="setEmployeeId();">
                                    <option value="-1">Выберите сотрудника</option>
                                </select>
                            </td>
                        </tr>
                    </core:when>
                    <core:otherwise>
                        <tr>
                            <td colspan="3"><i>${registerCommandForm.fio}</i></td>
                        </tr>
                    </core:otherwise>
                </core:choose>
            <tr>
                <td>Логин: </td>
                <td class="input-control text" data-role="input-control">
                    <form:input class="register_blockable" style="height: auto" path="login"/> 
                </td>
                <td><form:errors path="login"/> </td>
            </tr>
            <tr>
                <td>Пароль: </td>
                <td class="input-control password" data-role="input-control">
                    <form:password class="register_blockable" style="height: auto" path="password"/> 
                </td>
                <td><form:errors path="password"/> </td>
            </tr>
            <tr>
                <td>Повторите пароль: </td>
                <td class="input-control password" data-role="input-control">
                    <form:password class="register_blockable" style="height: auto" path="confirmPassword"/> 
                </td>
                <td><form:errors path="confirmPassword"/> </td>
            </tr>
            <tr>
                <td>Выдать права: </td>
                <td class="input-control checkbox" data-role="input-control">
                    <label class="inline-block">
                        <form:checkbox class="register_blockable" path="hr"/>
                        <span class="check"></span>
                        HR
                    </label>
                </td>
                <td class="input-control checkbox" data-role="input-control">
                    <label class="inline-block">
                        <form:checkbox class="register_blockable" path="manager"/>
                        <span class="check"></span>
                        Менеджер 
                    </label>
                </td>
            </tr>
            <tr>
                <td><input id="reset_register" name="reset_register" class="register_blockable" value="Сброс" type="reset"></td>
                <td colspan="2"><input id="register_submit" name="register_submit" class="register_blockable" value="ОК" type="button" onclick="submitNewUser();"></td>
            </tr>
        </table>
    </form:form>
</div>